#import "HttpServerURL.h"
static HttpServerURL* httpServerURL;

@implementation HttpServerURL
@synthesize  portalURL;
@synthesize  serverURL;
@synthesize  baseServerURL;
@synthesize  serverUrlNoFilter;
@synthesize  serverImgUrl;
@synthesize  serverIconUrlExt;
@synthesize  serverFileUrl;
@synthesize uploadServerURL;


+ (HttpServerURL*) GetInstance
{
    if (httpServerURL == NULL) 
    {
        httpServerURL = [[HttpServerURL alloc]init];
        
        httpServerURL.portalURL = @"http://portal.maoyi365.com.cn/mobile?code=";
        
        httpServerURL.baseServerURL = @"https://172.16.15.130:8443/maoyi365";
//        httpServerURL.baseServerURL = @"http://172.16.15.151:8080";
//        httpServerURL.baseServerURL = @"https://172.16.15.143:8443/maoyi365";
//        httpServerURL.baseServerURL = @"https://localhost:8443/maoyi365";
//        httpServerURL.baseServerURL = @"http://172.16.15.141:8088";
//        httpServerURL.baseServerURL = @"http://172.16.15.159:8080";
//        httpServerURL.baseServerURL = @"http://172.16.15.136:8088/maoyi365";
        
        httpServerURL.serverURL = [NSString stringWithFormat:@"%@/mobile",httpServerURL.baseServerURL];
        httpServerURL.serverUrlNoFilter = [NSString stringWithFormat:@"%@/mobile?login",httpServerURL.baseServerURL];
        httpServerURL.serverImgUrl = [NSString stringWithFormat:@"%@/displayCloudImage.phone?file_id=",httpServerURL.baseServerURL];
        httpServerURL.serverFileUrl = [NSString stringWithFormat:@"%@/downloadCloudFile.svt?file_id=",httpServerURL.baseServerURL]; 
        httpServerURL.serverIconUrlExt = @"&from_phone=iPhone&width=48&height=48";
        httpServerURL.uploadServerURL = [NSString stringWithFormat:@"%@/uploadmobile?login",httpServerURL.baseServerURL];
    }
    return httpServerURL;
}

- (void) SetAllServerURL:(NSString *)baseUrl
{
    NSString *tmp_url=[[[NSString alloc] initWithString:baseUrl] autorelease];
    //去掉结尾的/
    NSString *tmp1=[tmp_url substringFromIndex:[tmp_url length]-1];
    if ([tmp1 isEqualToString:@"/"]){
        tmp_url=[tmp_url substringToIndex:[tmp_url length]-1];
    }
    //修改为https://
    //http://test.app.maoyi365.com.cn
    tmp1=[tmp_url substringToIndex:7];
    if ([tmp1 isEqualToString:@"http://"]){
        tmp_url=[NSString stringWithFormat:@"https://%@",[tmp_url substringFromIndex:7]];
    }

    httpServerURL.baseServerURL = [NSString stringWithFormat:@"%@",tmp_url];
    httpServerURL.serverURL = [NSString stringWithFormat:@"%@/mobile",httpServerURL.baseServerURL];
    httpServerURL.serverUrlNoFilter = [NSString stringWithFormat:@"%@/mobile?login",httpServerURL.baseServerURL];
    httpServerURL.serverImgUrl = [NSString stringWithFormat:@"%@/displayCloudImage.phone?file_id=",httpServerURL.baseServerURL];        
    httpServerURL.serverImgUrl = [NSString stringWithFormat:@"%@/downloadCloudFile.svt?file_id=",httpServerURL.baseServerURL];      
    httpServerURL.serverFileUrl = [NSString stringWithFormat:@"%@/downloadCloudFile.svt?file_id=",httpServerURL.baseServerURL]; 
    httpServerURL.uploadServerURL = [NSString stringWithFormat:@"%@/uploadmobile?login",httpServerURL.baseServerURL];
//    [tmp_url release];
}

- (void) PrintAllServerURL
{
    NSLog(@"portalURL=%@",httpServerURL.portalURL);
    NSLog(@"baseServerURL=%@",httpServerURL.baseServerURL);
    NSLog(@"serverURL=%@",httpServerURL.serverURL);
    NSLog(@"serverUrlNoFilter=%@",httpServerURL.serverUrlNoFilter);
    NSLog(@"serverImgUrl=%@",httpServerURL.serverImgUrl);
    NSLog(@"serverIconUrlExt=%@",httpServerURL.serverIconUrlExt);
    
}
@end
